using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace SmartContentUI.Document
{
    public partial class ViewInfo : UserControl
    {

        private ImageList imglst;

        public ViewInfo()
        {
            InitializeComponent();
            initImgList();
        }

        public void Clear()
        {
            this.exListView1.Items.Clear();
        }
        public void createInfo(SmartContentDB.Interfaces.Field[] column, string[] values)
        {
            createColumnHeader();

            Util.EXListViewItem item;
            for (int i = 0; i < column.Length; i++)
            {
                item = new Util.EXListViewItem();
                item.Text = column[i].getName();

                if (column[i].getType().ToUpper().Equals("TINYINT"))
                {
                    if (values[i].Equals("1"))
                        item.SubItems.Add(new Util.EXMultipleImagesListViewSubItem(new ArrayList(new object[] { imglst.Images[0] }), "1"));
                    else
                        item.SubItems.Add(new Util.EXMultipleImagesListViewSubItem(new ArrayList(new object[] { imglst.Images[1] }), "0"));
                }
                else
                {
                    item.SubItems.Add(values[i]);
                }
                item.Editable = false;
                this.exListView1.Items.Add(item);
            }
        }

        private void initImgList()
        {
            imglst = new ImageList();
            imglst.ColorDepth = ColorDepth.Depth32Bit;
            imglst.Images.Add(global::SmartContentUI.Properties.Resources._true);
            imglst.Images.Add(global::SmartContentUI.Properties.Resources._false);
        }

        private void createColumnHeader()
        {
            Util.EXEditableColumnHeader col;
            int colWidth = this.exListView1.Width / 2;
            if (colWidth < 90)
                colWidth = 90;

            col = new Util.EXEditableColumnHeader("Campo");
            col.TextAlign = HorizontalAlignment.Left;
            col.Width = colWidth;
            this.exListView1.Columns.Add(col);

            col = new Util.EXEditableColumnHeader("Valor");
            col.TextAlign = HorizontalAlignment.Center;
            col.Width = colWidth;
            this.exListView1.Columns.Add(col);
        }
    }
}
